package com.array;

/**
 * @Author WaveHi
 * @Date 28/7/2021 上午 11:52
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description 输出数组信息
 */
public class UseArrayDemo7 {

    public static void main(String[] args) {

        //定义数组
        int[] nums = {1,23,4,123,343,2};

        //使用for循环结构输出数组
        System.out.print("[");
        for(int index = 0;index < nums.length;index++){
            //判断是否为最后一个元素
            if(index == nums.length - 1){
                System.out.print(nums[index] + "");
            }else {
                System.out.print(nums[index] + ",");
            }
        }
        System.out.println("]");

    }

}
